package ltd.hanamaki.study.collectionframe;

import java.io.*;
import java.util.Properties;

public class PropertiesDemo02 {

    public static void main(String[] args) {

        Properties properties = new Properties();

        /* 加载外部文件中的信息 */
        FileInputStream fileInputStream = null;
        try {
            /* 相对路径：从项目开始  */
            File file = new File("javaStudy/src/ltd/hanamaki/study/collectionframe/my.ini");
            fileInputStream = new FileInputStream(file);
            properties.load(fileInputStream);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                fileInputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        System.out.println(properties);
        System.out.println(properties.getProperty("username"));


    }
}
